local bugong = fk.CreateSkill{
  name = "lingling__bugong",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["lingling__bugong"] = "不攻",
  [":lingling__bugong"] = "锁定技，当你对体力为1的角色造成伤害时，若其有牌，你弃置其两张牌防止之（不足全弃），然后你摸一张牌。",

  ["#lingling__bugong-discard"] = "不攻：弃置 %dest 两张牌，防止你对其造成的伤害",
}

bugong:addEffect(fk.DamageCaused, {
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(bugong.name) and
      data.to.hp == 1 and not data.to:isNude()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    data:preventDamage()
    if data.to == player then
      room:askToDiscard(player, {
        min_num = 2,
        max_num = 2,
        include_equip = true,
        skill_name = bugong.name,
        cancelable = false,
        prompt = "#lingling__bugong-discard::"..player.id,
      })
    else
      local cards = room:askToChooseCards(player, {
        target = data.to,
        min = 2,
        max = 2,
        flag = "he",
        skill_name = bugong.name,
        prompt = "#lingling__bugong-discard::"..data.to.id,
      })
      room:throwCard(cards, bugong.name, data.to, player)
    end
    if not player.dead then
      player:drawCards(1, bugong.name)
    end
  end,
})

return bugong
